<!--2018/12/25 11:19. by soft-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <link rel="stylesheet" href="${root}/static/css/index.css">
  <link rel="stylesheet" href="${root}/static/layui/css/layui.css" media="all">
  <title>用户注册</title>
</head>
<body class="layui-bg-gray">
<nav class="layui-bg-cyan">
  <ul class="layui-nav layui-bg-cyan layui-container text-right">
    <li class="nav-title">
      <a href=""><img src="${root}/static/image/wxxyu.gif" height="50"></a>
    </li>
    <li class="layui-nav-item"><a href="${root}/login">登录</a></li>
  </ul>
</nav>
<div class="layui-container">
  <div style="margin: 15px 0;" class="layui-card">
    <div class="layui-card-body">
      <h3 style="font-weight: bold;">当前位置：<span>用户注册</span></h3>
    </div>
  </div>

  <div class="layui-card">
    <div class="layui-card-body layui-row">
      <form class="layui-form" lay-filter="register-form">
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
              <input name="name" lay-verType="tips" lay-verify="required" placeholder="请输入您的名字" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">工号</label>
            <div class="layui-input-block">
              <input name="jobNum" lay-verType="tips" lay-verify="required" placeholder="工号/登录账号" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
              <select name="sex">
                <option value="0">保密</option>
                <option value="1" selected>男</option>
                <option value="2">女</option>
              </select>
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">生日</label>
            <div class="layui-input-block">
              <input id="birthday" name="birthday" lay-verType="tips" lay-verify="required" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">电话</label>
            <div class="layui-input-block">
              <input type="tel" name="tel" lay-verType="tips" lay-verify="phone" placeholder="请输入您的电话"
                     class="layui-input" maxlength="11">
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
              <input type="email" name="email" lay-verType="tips" lay-verify="email" placeholder="请输入您的邮箱"
                     class="layui-input">
            </div>
          </div>
        </div>

        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">所在学院</label>
            <div class="layui-input-block">
              <select name="collageId" id="collage" lay-verType="tips" lay-filter="collageF">
                <option value="">电信学院</option>
              </select>
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">所在部门</label>
            <div class="layui-input-block">
              <select id="dept" name="deptId" lay-verType="tips">
                <option value="">人事部</option>
              </select>
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">现任职位</label>
            <div class="layui-input-block">
              <select id="duty" name="dutyId" lay-verType="tips" lay-filter="dutyF">
                <option value="">教授</option>
              </select>
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">职位等级</label>
            <div class="layui-input-block">
              <select id="dutyLevel" name="dutyLevel" lay-verType="tips">
                <option value="">一级</option>
              </select>
            </div>
          </div>
        </div>

        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-block">
              <input type="password" name="password" lay-verType="tips" lay-verify="required|pass" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">重复密码</label>
            <div class="layui-input-block">
              <input type="password" lay-verType="tips" lay-verify="required|somePwd" class="layui-input">
            </div>
          </div>
        </div>

        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">任职日期</label>
            <div class="layui-input-block">
              <input id="nDatetime" name="nDatetime" lay-verType="tips" lay-verify="required" class="layui-input">
            </div>
          </div>
        </div>

        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">验证码</label>
            <div class="layui-input-block" id="imgCode">
              <input placeholder="请输入验证码" name="code" class="layui-input" lay-verType="tips" lay-verify="required">
              <img src="${root}/verify">
            </div>
          </div>
        </div>

        <div class="layui-col-sm-offset6 layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn layui-btn-normal layui-btn-fluid" lay-submit>注 册</button>
            </div>
          </div>
        </div>
      </form>

    </div>
  </div>
</div>
<script src="${root}/static/js/common.js"></script>
<script src="${root}/static/layui/layui.js"></script>
<script>
  layui.use(['form', 'jquery', 'layer', 'laydate'], function () {
    var form = layui.form;
    var $ = layui.$;
    var layer = layui.layer;
    var laydate = layui.laydate;

    form.on('submit', function (obj) {
      $.post('${root}/user/none/register', obj.field, function (data) {
        if (data.status === 200) {
          layer.msg('注册成功！即将跳转登录...', {icon: 6, time: 1150});
          setTimeout(function () {
            location.href = '${root}/login';
          }, 1250);
        } else {
          layer.alert('注册失败：' + data.message, {title: '失败', icon: 5});
        }
      });
      return false;
    });

    form.verify({
      somePwd: function (value, elem) {
        var pwd = $('input[name="password"]').val();
        if (value !== pwd) {
          return '两次密码不一样！';
        }
      },
      pass: function (val, elem) {
        if (val.length < 6) {
          return "密码别小于6位哈";
        }
      }
    });

    // 部门、职位、职位等级设置
    var collage = $('#collage'),
        dept = $('#dept'),
        duty = $('#duty'),
        dutyLevel = $('#dutyLevel');
    deptDutyLink($, layer, form, collage, null, dept, duty, dutyLevel, '${root}');

    /// 不会改动的配置
    laydate.render({
      elem: '#birthday', //指定元素
      value: new Date('1990-01-01'),
      theme: '#3e8084'
    });
    laydate.render({
      elem: '#nDatetime', //指定元素
      value: new Date('2012-01-01'),
      theme: '#733784'
    });

    $('#imgCode img').click(function () {
      var suf = (Math.random() * 100).toFixed();
      this.src = "${root}/verify?" + suf;
    });
  });
</script>
</body>
</html>